package com.qcq.springcloud.controller;

import com.qcq.springcloud.pojo.User;
import com.qcq.springcloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：qcq
 * @date ：Created in 2020/11/26 20:14
 * @description：
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;
    // 获取端口
    @Value("${server.port}")
    private Integer port;

    @GetMapping("/{username}")
    public User queryByUsername(@PathVariable("username") String username) {
        //int i = 1/0;
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

        System.out.println("server port= " + port);
        return userService.queryByUsername(username);
    }
}
